﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using QLMB.Models;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace QLMB.ViewModels
{
    public class InfoFlight
    {
        private List<SelectListItem> _sbdi = new List<SelectListItem>();
        private List<SelectListItem> _sbden = new List<SelectListItem>();


        [DisplayName("San bay di")]
        [Required(ErrorMessage = "Vui long chon san bay di")]
        public string Sanbaydi {get; set;}
        
        [DisplayName("San bay den")]
        [Required(ErrorMessage = "Vui long chon san bay den")]
        public string Sanbayden {get; set;}

        public DateTime Ngaydi { get; set; }

        public DateTime Ngayve { get; set; }

        [Required(ErrorMessage = "Vui long chon loai chuyen bay")]
        public string Loaive { get; set; }

        [DisplayName("Nguoi lon")]
        public int SoNguoiLon { get; set; }

        [DisplayName("Tre em")]
        public int SoTreEm { get; set; }

        public int Loaidichvu { get; set; }
        public HANHKHACH Nguoidat { get; set; }
        public List<HANHKHACH> dsHK;

        public List<SelectListItem> Sbden
        {
            get { return _sbden; }
        }

        public List<SelectListItem> Sbdi
        {
            get{
                var db = new BookingEntities();
                IEnumerable<SelectListItem> items = db.DUONGBAYs
                  .Select(c => new SelectListItem
                  {
                      Value = c.SANBAY.MaSB,
                      Text = c.SANBAY.THANHPHO.TenTP
                  }).Distinct();
                _sbdi = items.ToList();
                return _sbdi;
            }
        }

        public List<SelectListItem> LayDSSBDen(string id)
        {
            var db = new BookingEntities();
            IEnumerable<SelectListItem> items = db.DUONGBAYs.Where(c => c.SanBayDi == id)
              .Select(c => new SelectListItem
              {
                  Value = c.SANBAY1.MaSB,
                  Text = c.SANBAY1.THANHPHO.TenTP
              }).Distinct();

            return  items.ToList();
        }
    }
}